clear
set more off

use "$statadir/preparers", clear
tostring b*, format(%6.3f) replace force

gen sortvar = 1*(var=="any_ertc") + 2*(var == "any_amendment") + 3*(var=="either")
sort sortvar


cap file close myfile
file open myfile using "$outdir/tables/preparers.tex", write replace

*************
*	Header	*
*************

file write myfile "  & \multicolumn{2}{c}{Counterfactual take-up} \\ "
file write myfile "	\cline{2-3} "
file write myfile " & On original return & On amended return \\ "
file write myfile " & (1) & (2) \\ "
file write myfile " \hline "

file write myfile "Baseline &  `=b0[1]' &  `=b0[2]'  \\ "
file write myfile " \addlinespace[6pt] "

file write myfile "Replace below median &  `=b50[1]' &  `=b50[2]' \\ "
file write myfile " \addlinespace[6pt] "

file write myfile "Replace below 75th p'tile &  `=b75[1]' &  `=b75[2]'    \\ "
file write myfile " \addlinespace[6pt] "

file write myfile "Replace below 90th p'tile &  `=b90[1]' &  `=b90[2]'  \\ "

cap file close myfile
